home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’93 / Inside Mac Movie Toolbox Code / mtb3.c < prev    next >
Text File  |  1992-10-22  |  2KB  |  84 lines

  1. //    Copyright:    © 1992 by Apple Computer, Inc., all rights reserved.
  2.  
  3. #include "mtb.h"
  4.  
  5. void main (void)
  6. {
  7.     MovieController                aController;
  8.     WindowPtr                     aWindow;
  9.     Rect                         aRect;
  10.     Movie                         aMovie;
  11.     Boolean                     done = false;
  12.     OSErr                         err;
  13.     EventRecord                 theEvent;
  14.     WindowPtr                     whichWindow;
  15.     short                         part;
  16.  
  17.     InitGraf (&qd.thePort);
  18.     InitFonts ();
  19.     InitWindows ();
  20.     InitMenus ();
  21.     TEInit ();
  22.     InitDialogs (nil);
  23.     
  24.     if (!IsQuickTimeInstalled()) {
  25.         CheckError(-1,"\pPlease install QuickTime and try again.");
  26.         }
  27.     
  28.     err = EnterMovies ();
  29.     if (err) return;
  30.     
  31.     SetRect (&aRect, 100, 100, 200, 200);
  32.     aWindow = NewCWindow (nil, &aRect, "\pMovie", 
  33.                             false, noGrowDocProc, 
  34.                                 (WindowPtr)-1, true, 0);
  35.     SetPort (aWindow);
  36.     aMovie = GetMovie ();
  37.     if (aMovie == nil) return;
  38.     
  39.     SetRect(&aRect, 0, 0, 100, 100);
  40.     aController = NewMovieController (aMovie, &aRect, mcTopLeftMovie);
  41.     if (aController == nil) return;
  42.  
  43.     err = MCGetControllerBoundsRect(aController, &aRect);
  44.     SizeWindow (aWindow, aRect.right,
  45.                      aRect.bottom, true);
  46.     ShowWindow (aWindow);
  47.     err = MCDoAction (aController,
  48.                              mcActionSetKeysEnabled, (Ptr) true);
  49.                              
  50.     while (!done) {
  51.         WaitNextEvent(everyEvent, &theEvent, 0, nil );
  52.         if (!MCIsPlayerEvent(aController, &theEvent)) {
  53.             switch (theEvent.what) {
  54.                 case updateEvt:    
  55.                     whichWindow = (WindowPtr)theEvent.message;
  56.                     BeginUpdate (whichWindow);
  57.                     EraseRect (&whichWindow->portRect);
  58.                     EndUpdate (whichWindow);
  59.                     break;
  60.                 case mouseDown:    
  61.                     part = FindWindow (theEvent.where,
  62.                                                 &whichWindow);
  63.                     if (whichWindow == aWindow) {
  64.                         switch (part) {
  65.                             case inGoAway:    
  66.                                 done = TrackGoAway (whichWindow,
  67.                                                     theEvent.where);
  68.                                 break;
  69.                                 
  70.                             case inDrag:    
  71.                                 DragWindow (whichWindow,
  72.                                                  theEvent.where,
  73.                                                  &qd.screenBits.bounds);
  74.                                 break;
  75.                         }
  76.                     }
  77.             }
  78.         }
  79.     }
  80.     DisposeMovieController (aController);
  81.     DisposeMovie (aMovie);
  82.     DisposeWindow(aWindow);
  83. }
  84.